package com.xuxueli.applyModules.utils;


import java.io.File;
import java.security.MessageDigest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import org.apache.shiro.crypto.hash.SimpleHash;
/**
 * 说明：MD5处理
 *
 * 修改时间：2014年9月20日
 * @version
 */
public class MD5 {

    public static String md5(String str) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(str.getBytes());
            byte b[] = md.digest();

            int i;

            StringBuffer buf = new StringBuffer("");
            for (int offset = 0; offset < b.length; offset++) {
                i = b[offset];
                if (i < 0)
                    i += 256;
                if (i < 16)
                    buf.append("0");
                buf.append(Integer.toHexString(i));
            }
            str = buf.toString();
        } catch (Exception e) {
            e.printStackTrace();

        }
        return str;
    }

    public static void main(String[] args) {
		/*System.out.println(md5("31119@qq.com"+"123456"));
		System.out.println(md5("mj1"));
		System.out.println(md5("1"));
		System.out.println(md5("qiu1234"));
		String filePath = FileUpload.getFile();
		System.out.println(filePath);
		System.out.println(Tools.convertBase64ToStr("5LiJ5qyh"));
		System.out.println(Tools.convertStrToBase64("三次"));
		System.out.println(Tools.convertStrToBase64("1"));
		String dsd = "11-10-2016-05-01";
		String d = dsd.replace("-", ",");
		String[] ds = d.split(",");
		System.out.println(ds[0]);
		System.out.println(ds[1]);*/
        //绑定用户名和密码并且加密
        System.out.println(new SimpleHash("SHA-1", "admin", "zy123678"));
        String path = FileUpload.getTXTFile();
        File filesd = new File(path);
        File[] files = filesd.listFiles();
        System.out.println(files);
        List<String> pList = new ArrayList<>();
        pList.add("1");
        pList.add("1");
        pList.add("2017-08-10");
        pList.add("2017-08-10");
        String dsd = "1";
        String dsds = "2017-08-10";
        System.out.println(pList);
        if (pList.contains(dsd) && pList.contains(dsds)) {
            System.out.println("sd***");
        } else {
            System.out.println("***sd");
        }
        String startDateString = "2017-08-01";
        SimpleDateFormat sdft = new SimpleDateFormat("yyyy-MM-dd");
        Calendar calendar = Calendar.getInstance();
        try {
            calendar.setTime(sdft.parse(startDateString));
            //calendar.add(Calendar.DAY_OF_MONTH, -1);
            int year = calendar.get(Calendar.YEAR);
            System.out.println(year);
            int month = calendar.get(Calendar.MONTH) + 1;
            System.out.println(month);
            int day = calendar.get(Calendar.DAY_OF_MONTH);
            System.out.println(day);
        } catch (ParseException e) {
            e.printStackTrace();
        }

    }
}